file (GLOB COMMON_SOURCE_FILES "common/*.cc")
file (GLOB SERVER_SOURCE_FILES "server/*.cc")
file (GLOB CLIENT_SOURCE_FILES "client/*.cc")
file (GLOB INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/pistache/*.h)

set(SOURCE_FILES
	${COMMON_SOURCE_FILES}
	${SERVER_SOURCE_FILES}
	${CLIENT_SOURCE_FILES}
	${INCLUDE_FILES}
)

add_compile_options(-fPIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -pthread")

http_layer_find_gtest()
http_layer_find_libevent()
http_layer_find_openssl()
http_layer_find_rapidjson()

add_library(HttpLayer STATIC ${SOURCE_FILES})

target_link_libraries(HttpLayer PRIVATE -Wl,-rpath='$ORIGIN'
	http_layer_openssl_internal
)

target_include_directories(HttpLayer PUBLIC
	${CMAKE_CURRENT_SOURCE_DIR}/../include
	${CMAKE_CURRENT_SOURCE_DIR}/winlog
	$<TARGET_PROPERTY:http_layer_openssl_internal,INTERFACE_INCLUDE_DIRECTORIES>
	$<TARGET_PROPERTY:http_layer_spdlog_internal,INTERFACE_INCLUDE_DIRECTORIES>
	$<TARGET_PROPERTY:http_layer_rapidjson_internal,INTERFACE_INCLUDE_DIRECTORIES>
	$<TARGET_PROPERTY:http_layer_gtest_internal,INTERFACE_INCLUDE_DIRECTORIES>
	$<TARGET_PROPERTY:http_layer_libevent_internal,INTERFACE_INCLUDE_DIRECTORIES>
)

if (HTTP_LAYER_USE_SSL)
	target_compile_definitions(HttpLayer PUBLIC PISTACHE_USE_SSL)
endif ()
